<template>
	<view class="newsbox">
		<view class="pic">
			<image :src="item.picurl" alt="" />
		</view>
		<view class="text">
			<view class="title">{{item.title}}</view>
			<view class="info" v-if="!item.looktime">
				<text>{{item.author}}</text>
				<text>{{item.hits}}浏览</text>
			</view>
			<view class="info" v-else>
				<text>浏览时间：{{item.looktime}}</text>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "newsbox",
		props:{
			item:{
				type:Object,
				default(){
					return{
						title:"组件内默认内容",
						author:"李四",
						hits:668,
						picurl:"../../static/images/nopic.jpg",
						looktime:'2023-03-20 12:00:16'
					}
				}
			}
		},
		data() {
			return {

			};
		},
		
	}
</script>

<style lang="scss" scoped>
	.newsbox {
		display: flex;
		justify-content: space-between;

		.pic {
			width: 230rpx;
			height: 160rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.text {
			padding-left: 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			flex: 1;

			.title {
				font-size: 36rpx;
				color: #333;
				text-overflow: -o-ellipsis-lastline;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 2;
				line-clamp: 2;
				-webkit-box-orient: vertical;
			}

			.info {
				font-size: 26rpx;
				color: #999;

				text {
					padding-right: 30rpx;
				}
			}
		}
	}
</style>
